package com.suxin.netty.coder;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author Tang
 * @classname MyClientHandler
 * @description [ TODO ]
 * @date 2021/1/8 22:01
 */
public class MyClientHandler extends SimpleChannelInboundHandler<Integer> {

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("[" + ctx.channel().localAddress() + "] 发送给服务器：" + 88);
        ctx.writeAndFlush(88);
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Integer msg) throws Exception {
        System.out.println("[" + ctx.channel().localAddress() + "] 读取服务器的消息：" + msg);
    }
}